package pearson.automation.assets;

import pearson.automation.forms.CourseSelectDialog;
import pearson.automation.forms.LightBoxForm;
import pearson.automation.forms.RemoveConfirmationForm;

public class AssetWithOutRollOver extends BaseAsset {

    public AssetWithOutRollOver(String assetName) {
        super(assetName);
    }
    
    public AssetWithOutRollOver(String assetName, int index) {
        super(assetName, index);
    }
    
    public AssetWithOutRollOver(String xpath, boolean byXPath) {
        super(xpath, byXPath);
    }

    @Override
    protected String formatLogMsg(String message) {
        return "Asset With Out Roll Up";
    }

    public RemoveConfirmationForm clickRemove() {
        remove.clickAndWait();
        return new RemoveConfirmationForm();
    }
    
    public String getAssetType() {
        return element.getElement().getAttribute("data-content-type");
    }
    
    public CourseSelectDialog clickAddToButton() {
        browser.waitForPageToLoad();
        addTo.clickAndWait();
        return new CourseSelectDialog();
    }

    public void clickNewButton() {
        newCourse.clickAndWait();
    }
    
    public LightBoxForm clickPreviewButton() {
        preview.clickAndWait();
        return new LightBoxForm();
    }
    
    public boolean canBeAddedToMyLibrary() {
        return addToLibrary.isPresent();
    }
    
    public boolean isAddedToMyLibrary() {
        //Some time for button to change
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return remove.isPresent();
    }
    
    public void clickAddToMyLibrary() {
        addToLibrary.clickAndWait();
    }

    public String getDataContentRef() {
        return element.getElement().getAttribute("data-content-ref");
    }

    
}
